class Solution
{
public:
    vector<int> maximumBeauty(vector<vector<int>> &items, vector<int> &queries)
    {
        items.push_back({0, 0});
        sort(items.begin(), items.end());
        int n = items.size();
        for (int i = 1; i < n; ++i)
        {
            items[i][1] = max(items[i][1], items[i - 1][1]);
        }
        int m = queries.size();
        for (int i = 0; i < m; ++i)
        {
            queries[i] = items[upper_bound(items.begin(), items.end(), queries[i], [&](int priceUpperBound, auto &item)
                                           { return priceUpperBound < item[0]; }) -
                               items.begin() - 1][1];
        }
        return queries;
    }
};